package com.pi.shisan.service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pi.shisan.service.domain.LunarMapping;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LunarMappingMapper extends BaseMapper<LunarMapping> {

    @Select("select id from lunar_mapping where dayint = 20500122 limit 1")
    Long checkHasInitFinished();

    /**
     * 获取下一个指定的中国日期
     * @param cdayint
     * @param dayint
     * @return
     */
    @Select("select * from lunar_mapping where cdayint = #{cdayint} and dayint >= #{dayint} order by dayint asc limit 1")
    LunarMapping selectNext(@Param("cdayint") Integer cdayint, @Param("dayint") Integer dayint);


    /**
     * 用于如果没有成功初始化完成，则清空表重新初始化
     */
    @Delete("delete from lunar_mapping")
    void clear();
}
